<!DOCTYPE html>
<!-- /* -->
<!--  * Copyright 2016-2021 the original author.All rights reserved. -->
<!--  * AiTeaSoft.com-->
<!--  * Kingstar(aiteasoft@163.com) -->
<!--  * The license,see the LICENSE file. -->
<!--  * Create on 2021-01-18 18:29:21 -->
<!--  * v1.9.01 -->
<!--  */ -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>scores</title>
	<link rel="stylesheet" type="text/css" href="../css/je/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../css/je/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../css/je/themes/color.css">
	<link rel="stylesheet" type="text/css" href="../css/je/themes/demo.css">
	<script type="text/javascript" src="../js/jquery.js"></script>
	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
<!--	<script type="text/javascript" src="../js/jqeEx.js"></script>  -->
	<script type="text/javascript" src="../js/js-ex2.js"></script>
	<script type="text/javascript" src="../js/jquery.edatagrid.js"></script>
<!--	<script type="text/javascript" src="../js/scores/scores.js"></script> -->
     <script type="text/javascript" src="../js/suid-jq.js"></script>
</head>
<body>
	<table id="dg" title="Data List" class="easyui-datagrid" style="width:950px;height:535px" idField="id"
			toolbar="#toolbar">
		<thead>
			<tr>
			    <th field="ck" checkbox="true"></th>
                 <th field="id"   hidden="true"  width="50" >ID</th>
                 <th field="classno"   width="50" >班级</th>
                 <th field="term"   width="50" >学期</th>
                 <th field="examno"   width="50" >考试批次</th>
                 <th field="subject"   width="50" >科目名称</th>
                 <th field="stuno"   width="50" >学号</th>
                 <th field="name"   width="50" >姓名</th>
                 <th field="teacherno"   width="50" >老师编号</th>
                 <th field="teachername"   width="50" >老师姓名</th>
                 <th field="score"   width="50"  editor="text">分数</th>
                 <th field="creater"   width="50" >创建者</th>
                 <th field="createtime"   width="95">创建时间</th>
                 <th field="updater"   width="50" >修改者</th>
                 <th field="remark"   width="50"  editor="text">备注</th>
                 <th field="status"   width="50" >状态</th>
			</tr>
		</thead>
			
	</table>
	<div id="toolbar">
	    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add()">Upload</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saveRow')">Save</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">Cancel</a>
	  
     <form name="formSearch" id="formSearch">
	    <span>班级:</span><input name="classno" style="line-height:26px;border:1px solid #ccc">
	    <span>学期:</span><input name="term" style="line-height:26px;border:1px solid #ccc">
	    <span>考试批次:</span><input name="examno" style="line-height:26px;border:1px solid #ccc">
	    <span>学号:</span><input name="stuno" style="line-height:26px;border:1px solid #ccc">
	    <span>姓名:</span><input name="name" style="line-height:26px;border:1px solid #ccc">
	    <span>分数:</span><input name="score" style="line-height:26px;border:1px solid #ccc">
	    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search"  plain="true" onclick="find()">Search</a>
     </form>
	 
	 </div>
	 
	 <div id="dlg-new" class="easyui-dialog" style="width:400px;height:200px;" data-options="fit:true,closed:true,modal:true,border:'thin',buttons:'#dlg-buttons-new'">
	 <div style="padding:20px 10px 40px 40px;">
		
<!-- 		<form id="formNew" method="post" novalidate accept-charset="UTF-8"> -->
<!-- <form id="uploadForm" method="post" enctype="multipart/form-data" > -->
		<form id="uploadForm" method="post" >
				<div style="margin-bottom:10px">
				<input id="file" name="file" type="file" ></input>
				</div>
				
<!-- 			<tr> -->
<!-- 				<td></td> -->
<!-- 				<td><input id="submitBt" type="button" value="Submit"></input></td> -->
<!-- 			</tr> -->
	  </form>

		</div>
	</div>
	<div id="dlg-buttons-new">
		<a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" plain="true" onclick="upload()" style="width:90px">Save</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" plain="true" onclick="closeUpload()" style="width:90px">Cancel</a>
    </div>
	
	<script type="text/javascript">
	
	/*
	 * Copyright 2016-2021 the original author.All rights reserved.
	 * AiTeasoft.com
	 * Kingstar(aiteasoft@163.com)
	 * The license,see the LICENSE file.
	 */
	 
	 $(function(){
			 $("#dg").edatagrid({
                 fit : true,
				 height:'auto',
//               height:"535px",
//				 singleSelect:false,
//				 collapsible:true,
				 method:'get',
				 pagination:true,
				 rownumbers:true,
				 url: rootpath+'/scoresForTeacher/list',
				 
				 onLoadSuccess:function(result){
					if (result.errorMsg){
						$.messager.show({
							title: 'Error',
							msg: result.errorMsg
						});
					} else {
						  //...
					} 
				 } ,
		        
	             onLoadError:function(e){
			    	$.messager.show({
					title: '加载错误',
					msg: e.status+"  :  "+e.statusText
				   });
		        },
		        
		         onClickRow:function(rowIndex){
		        	 $(this).datagrid('clearSelections');
		        	 $(this).edatagrid('selectRow', rowIndex);
			     },
		        
		         onSave: function (index, row) {
		        	update(row);
		          }
			});
			 
			 
// 		     alert("turnPage---");
		     turnPage("scoresForTeacher"); 
	 });  

		function update(data){
			   $.ajax({ 
			    type:'post',  
			    url:rootpath+'/scoresForTeacher/edit', 
			    data:data,  
			    dataType:'json', 
			    
			    error:function(e){  
                    $.messager.show({
						title: 'Error',
						msg: e.status+"  :  "+e.statusText
					});
                }, 
			    success: function(result){
				if (result.errorMsg){
					$.messager.show({
						title: 'Error',
						msg: result.errorMsg
					});
				} else {
					$.messager.show({
						title: 'Successfully',
						msg: 'Successfully!'
					});
					 $("#dg").edatagrid("getPager").pagination('refresh', {
	                        pageNumber : 1               //fix easyui bug
	                    });
					 
					$('#dg').edatagrid('reload');
				}
			}
		});
		}
	
		function find(){
           var page=1;
           var pageSize=$("#dg").edatagrid("getPager").data("pagination").options.pageSize;
           
    	 /* var data={};
		    if($('#id').val()!=""){
			data.id=$('#id').val();
		   } */
 			var data = $("#formSearch").serializeFilterNull();
// 		   alert(data);
 			$.post(rootpath+'/scoresForTeacher/list?page='+page+'&rows='+pageSize,data,
			     function(result){
 				
			  	    if (result.errorMsg){
				    	$.messager.show({	// show error message
						  title: 'Error',
						  msg: result.errorMsg
					 });
				    }
 				
				      if (result){
	                    //将搜索结果显示在当前页面
	                    $("#dg").edatagrid("loadData", result.rows);
	                    $("#dg").edatagrid("getPager").pagination('refresh', {
	                        total: result.total
	                    });
	                }
			},'json'); 
		}
		
		
		
		 function closeUpload(){
				$('#dlg-new').dialog('close');
		  }
		 
			function add(){ //打开一个对话框
				$('#dlg-new').dialog('open').dialog('center').dialog('setTitle','Upload');
				$('#uploadForm').form('clear');
			}
			
			function upload(){
				
						if ($('#file').val().trim() == "") {
							alert("请选择要上传的文件!");
							return;
						}
							  
// 				             var form=document.getElementById("uploadForm");
// 				             form.action = rootpath+'/scoresForTeacher/upload';
// 				             form.submit();
//				 			  alert("upload...");
							  
// 			 var data = $("#uploadForm").serialize();
//                       var formData=new FormData($("#uploadForm"));
                       var formData=new FormData($("#uploadForm")[0]);
//                       var formData=new FormData($("form")[0]);
//                       alert(formData);
				   $.ajax({ 
// 				    type:'post',  
// 				    cache: false,
// // 					contentType: "multipart/form-data",
// 				    url:rootpath+'/scoresForTeacher/upload', 
// 				    data:data,  
// // 				    dataType:'json', 
//                    processData:false,

                     data:formData,
                     type:"post",
                     async:"false",
                     cache: false,
                     processData: false,//一定要加
                     contentType: false,//一定要加
                     url:rootpath+'/scoresForTeacher/upload', 
                     
				    error:function(e){  
	                    $.messager.show({
							title: 'Error',
							msg: e.status+"  :  "+e.statusText
						});
	                }, 
				    
				   success: function(result){
					if (result.errorMsg){
						$.messager.show({
							title: 'Error',
							msg: result.errorMsg
						});
					} else {
						$.messager.show({
							title: 'Successfully',
							msg: result.msg
						});
						$('#dlg-new').dialog('close');
						$('#dg').datagrid('reload');
					}
				}
			}); 
			
			}
			
			
			/*	
			$(function(){
				 //获取页面分页对象
 			    var p = $('#dg').datagrid('getPager');
			    if (p){
			           $(p).pagination({
			             onSelectPage:function (page,pageSize) {

 		             	   var data = $("#formSearch").serializeFilterNull();
		                   alert(data);
			        		
			      			$.post(rootpath+'/scoresForTeacher/list?page='+page+'&rows='+pageSize,data,
			      				     function(result){
			      					      if (result){
//		 	      		                    $("#dg").datagrid("loadData", result.rows);  //可以
		                                    $("#dg").datagrid("loadData", result);
			      		                    $("#dg").datagrid("getPager").pagination('refresh', {
			      		                        total: result.total
			      	 	                        ,
			      	 	                        pageNumber : page
			      		                    });
			      		                }
			      				},'json'); 
			              } 
			           });
			     } 

			 });	*/
			
		
		
	</script>
	
</body>
</html>